home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / gs_dps2.ps < prev    next >
Encoding:
Text File  |  1997-05-21  |  5.8 KB  |  189 lines

  1. %    Copyright (C) 1990, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Initialization file for basic Display PostScript functions
  16. % that are also included in Level 2.
  17.  
  18. level2dict begin
  19.  
  20. % ------ Halftones ------ %
  21.  
  22. /.makestackdict
  23.     { { counttomark -1 roll } forall .dicttomark
  24.     } bind def
  25. /currenthalftone        % - currenthalftone <dict>
  26.     { mark .currenthalftone
  27.        { { exch pop }        % halftone
  28.          { /HalftoneType 1        % screen
  29.         { /Frequency /Angle /SpotFunction }
  30.            .makestackdict
  31.          }
  32.          { /HalftoneType 2        % colorscreen
  33.         { /RedFrequency /RedAngle /RedSpotFunction
  34.           /GreenFrequency /GreenAngle /GreenSpotFunction
  35.           /BlueFrequency /BlueAngle /BlueSpotFunction
  36.           /GrayFrequency /GrayAngle /GraySpotFunction
  37.         }
  38.            .makestackdict
  39.          }
  40.        }
  41.       exch get exec
  42.     } odef
  43. % Define sethalftone so it converts all other types to type 5.
  44. /.sethalftoneRGBV    % <dict> <type> <keys> <keysRGBV>
  45.     { 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll
  46.       14 -2 roll mark 15 1 roll { /Gray /Blue /Green /Red }
  47.        {        % stack: v0 v1 v2 type keys comp
  48.          mark
  49.          2 index 0 get 8 -1 roll
  50.          4 index 1 get 9 -1 roll
  51.          6 index 2 get 10 -1 roll
  52.             % stack: type keys comp mark k0 v0 k1 v1 k2 v2
  53.          /HalftoneType 10 index .dicttomark
  54.          counttomark 2 roll
  55.        }
  56.       forall pop pop
  57.       /Default 1 index .dicttomark .sethalftone5
  58.     } bind def
  59. /sethalftone        % <dict> sethalftone -
  60.     { dup dup /HalftoneType get 1 sub
  61.        {  { mark /Default 2 index .dicttomark .sethalftone5 }
  62.           { 1 { /Frequency /Angle /SpotFunction }
  63.         { /RedFrequency /RedAngle /RedSpotFunction
  64.           /GreenFrequency /GreenAngle /GreenSpotFunction
  65.           /BlueFrequency /BlueAngle /BlueSpotFunction
  66.           /GrayFrequency /GrayAngle /GraySpotFunction
  67.         } .sethalftoneRGBV
  68.           }
  69.           { mark /Default 2 index .dicttomark .sethalftone5 }
  70.           { 3 { /Width /Height /Thresholds }
  71.         { /RedWidth /RedHeight /RedThresholds
  72.           /GreenWidth /GreenHeight /GreenThresholds
  73.           /BlueWidth /BlueHeight /BlueThresholds
  74.           /GrayWidth /GrayHeight /GrayThresholds
  75.         } .sethalftoneRGBV
  76.           }
  77.           { dup .sethalftone5 }
  78.        } exch get exec pop
  79.     } odef
  80. % Redefine setscreen and setcolorscreen to recognize halftone dictionaries,
  81. % and to insert the Frequency and Angle into Type 1 halftones, per
  82. % Adobe TN 5085.
  83. /.fixsethalftonescreen
  84.  { dup /HalftoneType get 1 eq
  85.     { dup wcheck not { dup length .copydict } if
  86.       dup /Frequency 4 index put
  87.       dup /Angle 3 index put
  88.     }
  89.    if
  90.  } bind def
  91. /setscreen        % <ignore*2> <dict> setscreen -
  92.     { dup type /dicttype eq
  93.        { dup .fixsethalftonescreen sethalftone pop pop pop }
  94.        { //setscreen }
  95.       ifelse
  96.     } odef
  97. /setcolorscreen        % <ignore*11> <dict> setcolorscreen -
  98.     { dup type /dicttype eq
  99.        { dup .fixsethalftonescreen sethalftone 12 { pop } repeat }
  100.        { //setcolorscreen }
  101.       ifelse
  102.     } odef
  103. % Redefine currentscreen and currentcolorscreen to extract the Frequency
  104. % and Angle from Type 1 halftones, per Adobe TN 5085.
  105. /.fixcurrenthalftonescreen    % <dict> .fix... <freq> <angle> <proc>
  106.  { dup /HalftoneType get 1 eq
  107.     { dup /Frequency get 1 index /Angle get }
  108.     { 60 0 }
  109.    ifelse 3 2 roll
  110.  } bind def
  111. /currentscreen        % - currentscreen 60 0 <dict>
  112.     { .currenthalftone
  113.        { { .fixcurrenthalftonescreen }    % halftone
  114.          { }                % screen
  115.          { 12 3 roll 9 { pop } repeat    % colorscreen
  116.            dup type /dicttype eq { .fixcurrenthalftonescreen } if
  117.          }
  118.        }
  119.       exch get exec
  120.     } odef
  121. /currentcolorscreen    % - currentcolorscreen (60 0 <dict>)*4
  122.     { .currenthalftone
  123.        { { .fixcurrenthalftonescreen 3 copy 6 copy }    % halftone
  124.          { 3 copy 6 copy }            % screen
  125.          { }                % colorscreen
  126.        }
  127.       exch get exec
  128.     } odef
  129.  
  130. % ------ User objects ------ %
  131.  
  132. /.localarray where {
  133.   pop
  134. } {
  135.   /.localarray {
  136.     currentglobal false setglobal
  137.     exch array exch setglobal
  138.   } bind def
  139. } ifelse
  140. % The name UserObjects may be rebound, but we need to make sure these
  141. % operators always refer to the binding in userdict (which may also be
  142. % rebound!).
  143. /.UserObjects {
  144.   //systemdict /userdict get /UserObjects
  145. } odef
  146. % In order to get proper error recovery behavior, we need to be careful
  147. % not to pop any operands from the stack until we're done.
  148. /defineuserobject {        % <index> <value> defineuserobject -
  149.   .UserObjects .knownget {
  150.     length 2 index le {
  151.       1 index 1 add .localarray userdict /UserObjects get
  152.       1 index copy pop
  153.       .UserObjects 3 -1 roll put
  154.     } if
  155.   } {
  156.     .UserObjects 3 index 1 add .localarray put
  157.   } ifelse
  158.   .UserObjects get 2 index 2 index put pop pop
  159. } odef
  160. /execuserobject {        % <index> execuserobject -
  161.   .UserObjects get 1 index get exch pop exec
  162. } odef
  163. /undefineuserobject {        % <index> undefineuserobject -
  164.   .UserObjects get 1 index null put pop
  165. } odef
  166.  
  167. % ------ User paths ------ %
  168.  
  169. % We define upath carefully so it won't leave garbage on the stack
  170. % if an error occurs.
  171. /upath {            % <bool> upath <array>
  172.     [ 1 index {/ucache cvx} if
  173.     true .pathbbox /setbbox cvx
  174.      {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx}
  175.     pathforall ] cvx exch pop
  176. } odef
  177.  
  178. % Dummy definitions for cache control operators
  179.  
  180. /ucachestatus
  181.     { mark 0 0 0 0 0 } odef
  182. /setucacheparams
  183.     { cleartomark } odef
  184.  
  185. end                % level2dict
  186.